﻿using System;
using System.ComponentModel;

namespace HalconDotNet
{
	/// <summary>
	///   The HALCON vector classes are intended to support the export of
	///   HDevelop code that uses vectors, and to pass vector arguments to
	///   procedures that use vector parameters. They are not intended to be
	///   used as generic container classes in user code. For this purpose,
	///   consider using standard container classes such as List&lt;T&gt;.
	/// </summary>
	// Token: 0x020000A1 RID: 161
	public class HObjectVector : HVector
	{
		/// <summary>
		///   Create empty vector of specified dimension. In case of dimension
		///   0 a leaf vector for an empty object is created
		/// </summary>
		// Token: 0x06002019 RID: 8217 RVA: 0x000BB310 File Offset: 0x000B9510
		public HObjectVector(int dimension) : base(dimension)
		{
			this.mObject = ((dimension <= 0) ? HObjectVector.GenEmptyObj() : null);
		}

		/// <summary>
		///   Create leaf vector of dimension 0 for the specified object
		/// </summary>
		// Token: 0x0600201A RID: 8218 RVA: 0x000BB32B File Offset: 0x000B952B
		public HObjectVector(HObject obj) : base(0)
		{
			if (obj == null || !obj.IsInitialized())
			{
				throw new HVectorAccessException("Uninitialized object not allowed in vector");
			}
			this.mObject = new HObject(obj);
		}

		/// <summary>
		///   Create copy of object vector
		/// </summary>
		// Token: 0x0600201B RID: 8219 RVA: 0x000BB356 File Offset: 0x000B9556
		public HObjectVector(HObjectVector vector) : base(vector)
		{
			if (this.mDimension <= 0)
			{
				this.mObject = new HObject(vector.mObject);
			}
		}

		// Token: 0x0600201C RID: 8220 RVA: 0x000BB379 File Offset: 0x000B9579
		private static HObject GenEmptyObj()
		{
			HObject hobject = new HObject();
			hobject.GenEmptyObj();
			return hobject;
		}

		// Token: 0x0600201D RID: 8221 RVA: 0x000BB386 File Offset: 0x000B9586
		protected override HVector GetDefaultElement()
		{
			return new HObjectVector(this.mDimension - 1);
		}

		/// <summary>
		///   Access to the object value for leaf vectors (dimension 0).
		///   Ownership of object resides with object vector and it will
		///   be disposed when the vector is disposed. Copy the object
		///   to create an object that will survive a vector dispose.
		///   When storing an object in the vector, it will be
		///   copied automatically.
		/// </summary>
		// Token: 0x170000A5 RID: 165
		// (get) Token: 0x0600201E RID: 8222 RVA: 0x000BB395 File Offset: 0x000B9595
		// (set) Token: 0x0600201F RID: 8223 RVA: 0x000BB3A4 File Offset: 0x000B95A4
		public HObject O
		{
			get
			{
				base.AssertDimension(0);
				return this.mObject;
			}
			set
			{
				base.AssertDimension(0);
				if (value == null || !value.IsInitialized())
				{
					throw new HVectorAccessException("Uninitialized object not allowed in vector");
				}
				this.mObject.Dispose();
				this.mObject = new HObject(value);
			}
		}

		/// <summary>
		///   Access to subvector at specified index. The vector will be
		///   enlarged to accomodate index, even in read access. The internal
		///   reference is returned to allow modifications of vector state. For
		///   read access, preferrably use the member function At(index).
		/// </summary>
		// Token: 0x170000A6 RID: 166
		public HObjectVector this[int index]
		{
			get
			{
				return (HObjectVector)base[index];
			}
			set
			{
				base[index] = value;
			}
		}

		/// <summary>
		///   Read access to subvector at specified index. An exception
		///   will be raised if index is out of range. The returned data
		///   is a copy and may be stored safely.
		/// </summary>
		// Token: 0x06002022 RID: 8226 RVA: 0x000BB3E8 File Offset: 0x000B95E8
		public new HObjectVector At(int index)
		{
			return (HObjectVector)base.At(index);
		}

		// Token: 0x06002023 RID: 8227 RVA: 0x000BB3F6 File Offset: 0x000B95F6
		protected override bool EqualsImpl(HVector vector)
		{
			if (this.mDimension >= 1)
			{
				return base.EqualsImpl(vector);
			}
			return ((HObjectVector)vector).O.TestEqualObj(this.O) != 0;
		}

		/// <summary>
		///   Returns true if vector has same dimension, lengths, and elements
		/// </summary>
		// Token: 0x06002024 RID: 8228 RVA: 0x000BB256 File Offset: 0x000B9456
		public bool VectorEqual(HObjectVector vector)
		{
			return this.EqualsImpl(vector);
		}

		/// <summary>
		///   Concatenate two vectors, creating new vector
		/// </summary>
		// Token: 0x06002025 RID: 8229 RVA: 0x000BB422 File Offset: 0x000B9622
		public HObjectVector Concat(HObjectVector vector)
		{
			return (HObjectVector)base.ConcatImpl(vector, false, true);
		}

		// Token: 0x06002026 RID: 8230 RVA: 0x000BB432 File Offset: 0x000B9632
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HObjectVector Concat(HObjectVector vector, bool clone)
		{
			return (HObjectVector)base.ConcatImpl(vector, false, clone);
		}

		/// <summary>
		///   Append vector to this vector
		/// </summary>
		// Token: 0x06002027 RID: 8231 RVA: 0x000BB442 File Offset: 0x000B9642
		public HObjectVector Append(HObjectVector vector)
		{
			return (HObjectVector)base.ConcatImpl(vector, true, true);
		}

		// Token: 0x06002028 RID: 8232 RVA: 0x000BB452 File Offset: 0x000B9652
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HObjectVector Append(HObjectVector vector, bool clone)
		{
			return (HObjectVector)base.ConcatImpl(vector, true, clone);
		}

		/// <summary>
		///   Insert vector at specified index
		/// </summary>
		// Token: 0x06002029 RID: 8233 RVA: 0x000BAF30 File Offset: 0x000B9130
		public HObjectVector Insert(int index, HObjectVector vector)
		{
			base.InsertImpl(index, vector, true);
			return this;
		}

		// Token: 0x0600202A RID: 8234 RVA: 0x000BAF3C File Offset: 0x000B913C
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HObjectVector Insert(int index, HObjectVector vector, bool clone)
		{
			base.InsertImpl(index, vector, clone);
			return this;
		}

		/// <summary>
		///   Remove element at specified index from this vector
		/// </summary>
		// Token: 0x0600202B RID: 8235 RVA: 0x000BAFBC File Offset: 0x000B91BC
		public new HObjectVector Remove(int index)
		{
			base.RemoveImpl(index);
			return this;
		}

		/// <summary>
		///   Remove all elements from this vector
		/// </summary>
		// Token: 0x0600202C RID: 8236 RVA: 0x000BB03C File Offset: 0x000B923C
		public new HObjectVector Clear()
		{
			this.ClearImpl();
			return this;
		}

		/// <summary>
		///    Create an independent copy of this vector
		/// </summary>
		// Token: 0x0600202D RID: 8237 RVA: 0x000BB462 File Offset: 0x000B9662
		public new HObjectVector Clone()
		{
			return (HObjectVector)this.CloneImpl();
		}

		// Token: 0x0600202E RID: 8238 RVA: 0x000BB46F File Offset: 0x000B966F
		protected override HVector CloneImpl()
		{
			return new HObjectVector(this);
		}

		// Token: 0x0600202F RID: 8239 RVA: 0x000BB477 File Offset: 0x000B9677
		protected override void DisposeLeafObject()
		{
			if (this.mDimension <= 0)
			{
				this.mObject.Dispose();
			}
		}

		/// <summary>
		///   Provides a simple string representation of the vector,
		///   which is mainly useful for debug outputs.
		/// </summary>
		// Token: 0x06002030 RID: 8240 RVA: 0x000BB490 File Offset: 0x000B9690
		public override string ToString()
		{
			if (this.mDimension <= 0)
			{
				return this.mObject.Key.ToString();
			}
			return base.ToString();
		}

		// Token: 0x0400118F RID: 4495
		private HObject mObject;
	}
}
